const {
    Mysql
} = require('../tools/utils');
module.exports = async (ctx) => {
    let {
        currentPage,
        pageSize
    } = ctx.query;
    let totalSql = `SELECT COUNT(*) FROM cSessionInfo RIGHT JOIN vip ON vip.uid = cSessionInfo.uid`
    let sql = `SELECT cSessionInfo.user_info,vip.* FROM cSessionInfo RIGHT JOIN vip ON vip.uid = cSessionInfo.uid ORDER BY create_time DESC LIMIT ${(currentPage-1)*pageSize},${pageSize}`;
    try {
        let list = await Mysql(sql);
        let total = await Mysql(totalSql);
        ctx.state.data = {
            total:Object.values(total[0])[0],
            list
        }
    } catch (error) {
        ctx.state.data = {
            list: []
        }
    }

}